/*
 * Copyright 2004-2005 aosft
 * 本软件及其所有拷贝的名称，与光盘上或本软件中注明的公司同在。
 * 本软件及文档享有版权，并受国家版权法及国际协约条款的保护。
 * 您不可以从本软件中去掉其版权声明；并保证为本软件的拷贝（本部或部分）* 复制版权声明。
 * 您同意制止以任何形式非法拷贝本软件及文档。
 * 版权信息参见：
 *      http://www.asoft.cn/licenses
 */

package com.asoft.examonline.teach.valid;

import javax.servlet.http.HttpServletRequest;

import org.apache.log4j.Logger;

import com.asoft.common.basedata.manager.TypeManager;
import com.asoft.common.basedata.model.Type;
import com.asoft.common.util.mvc.valid.UserValidator;
import com.asoft.common.util.mvc.valid.ValidatedResult;
import com.asoft.examonline.teach.manager.TeachResourceManager;
import com.asoft.examonline.teach.model.TeachResource;

/**
 * <p>Title: 新增的校验器</p>
 * <p>Description: </p>
 * <p>Copyright: Copyright (c) 2003</p>
 * <p>Company: aosft</p>
 * @ $Author: author $
 * @ $Date: 2005/02/16 01:04:14 $
 * @ $Revision: 1.7 $
 * @ created in 2005-11-14
 *
 */

public class UpdateTeachResourcesValidator extends UserValidator
{
        static Logger logger = Logger.getLogger(UpdateTeachResourcesValidator.class);
        
        private TypeManager typeManager;   
        
        private TeachResourceManager teachResourceManager;
        
        /**
         * @param typeManager 要设置的 typeManager
         */
        public void setTypeManager(TypeManager typeManager)
        {
                this.typeManager = typeManager;
        }
        
        /**
         * @param trManager 要设置的 trManager
         */
        public void setTeachResourceManager(TeachResourceManager teachResourceManager)
        {
                this.teachResourceManager = teachResourceManager;
        }

        /**
         * 新增前的校验
         *
         * @ param: HttpServletRequest request
         * @ param: ValidatedResult vr 校验结果存放器
         * @ param: String[] params 配置参数
         */
        public void validing(HttpServletRequest request,ValidatedResult vr,String[] params)
        {
                logger.info("开始进行教学资源删除前校验");
                TeachResource tr = (TeachResource)this.teachResourceManager.get(request.getParameter("id"));
                tr.setTitle(request.getParameter("title"));
                tr.setKnowledgePoint((Type)this.typeManager.get(request.getParameter("knowledgePointId")));
                tr.setDifficulty((Type)this.typeManager.get(request.getParameter("difficultyId")));
                tr.setPublishCompany((Type)this.typeManager.get(request.getParameter("publishCompanyId")));
                tr.setAuthorName(request.getParameter("authorName"));
                tr.setStandard(request.getParameter("standard"));
                tr.setElecText(request.getParameter("elecText"));
                tr.setClassicQuest(request.getParameter("classicQuest"));
                tr.setTeachDesign(request.getParameter("teachDesign"));
                tr.setCourseWare(request.getParameter("courseWare"));
                tr.setVideo(request.getParameter("video"));
                tr.setBackGround(request.getParameter("backGround"));
                tr.setOthers(request.getParameter("others"));
                tr.setCode(tr.getKnowledgePoint().getCode() + "_" + tr.getPublishCompany().getCode());
                request.setAttribute(TeachResource.class.getName(),tr);
        }
}
